function [dat]=r_woce(parameter,cruise)
% ---- Read WOCE parameter
switch cruise
 case 'a20'
     campagne=1;
 case 'a22'
     campagne=2;
 case 'a25'
     campagne=4;
 case 'ar24_a'
     campagne=9;
 case 'ar24_b'
     campagne=10;
 case 'ar04_f'
     campagne=6;
 case 'a02b'
     campagne=5;
 case 'ar19_d'
     campagne=12;
 case 'a24'
     campagne=3;
 case 'ar12_e'
     campagne=7;
 case 'ar12_g'
     campagne=8;
 case 'ar01_a'
     campagne=11;
 otherwise
  disp('Unknown Cruise !')
end

dirWOCE='/media/disk/OBSERVATIONS/CRUISES/WOCE';


% ---- Create the Structure ...        
dat = struct('dummy',1);
 

% Temperature or Salinity
if (strcmp(parameter,'T')) || (strcmp(parameter,'S'))
% ---- Chargement des donnees in situ de Temperature et de salinite
    if ~exist(dirWOCE,'dir')
        error('The data directory does not exist. Please double check dirWOCE in r_woce.m')
    end
[Woce_sec,stnnbr,stn_num,cast_num,day_stn,h_stn,date_dec,lon_stn,lat_stn,prof,ctdtmp,ctdsal,ctdoxy,minT,maxT,minS,maxS]=WOCE_CTD(campagne,dirWOCE);
dat.londata=lon_stn(find(~isnan(lon_stn)));
dat.latdata=lat_stn(find(~isnan(lat_stn)));
% Transformation des donnees in situ sous forme de matrice
clear date_diff_T prof_diff_T data_diff_T date_diff_S prof_diff_S data_diff_S
if (strcmp(parameter,'T'))
    [date_diff_T,prof_diff_T,data_diff_T]=transform_2Dmat(date_dec,prof,ctdtmp);
    dat.timedata=date_diff_T;
    dat.depthdata=prof_diff_T;
    dat.data=data_diff_T;
    dat.londata=repmat(dat.londata',[1 size(data_diff_T,2)]);
    dat.latdata=repmat(dat.latdata',[1 size(data_diff_T,2)]);
    
elseif strcmp(parameter,'S')
    [date_diff_S,prof_diff_S,data_diff_S]=transform_2Dmat(date_dec,prof,ctdsal);
    dat.timedata=date_diff_S;
    dat.depthdata=prof_diff_S;
    dat.data=data_diff_S;
    dat.londata=repmat(dat.londata',[1 size(data_diff_S,2)]);
    dat.latdata=repmat(dat.latdata',[1 size(data_diff_S,2)]);
end
clear ctdsal ctdtmp ctdoxy
clear date_dec prof
end

% Nitrates
if (strcmp(parameter,'NO3'))
    if ((campagne==5)||(campagne==2)||(campagne==4)||(campagne==6)||(campagne==3)||(campagne==7))
        
        
        
        % ---- Chargement des donnees in situ de Nitrates        
        clear prof_bot nit stn_num_bot
        [Woce_sec,stnnbr,stn_num,cast_num,day_stn,h_stn,date_dec,lon_stn_bot,lat_stn_bot,prof_bot,nit,stn_num_bot]=WOCE_bottle(campagne,dirWOCE);
        clear date_diff_NO3 prof_diff_NO3 data_diff_NO3
    
        %stn_num
        %date_dec(stn_num(~isnan(stn_num)))
        date_dec=date_dec(stn_num_bot(~isnan(stn_num_bot)));
        
        
        %[date_diff_NO3,prof_diff_NO3,data_diff_NO3]= transform_2Dmat(date_dec,prof_bot,nit);
        [date_diff_NO3,prof_diff_NO3,data_diff_NO3,lon_diff_NO3,lat_diff_NO3]=transform_2Dmat_bot(date_dec,prof_bot,nit,lon_stn_bot,lat_stn_bot);
        dat.timedata=date_diff_NO3;
        dat.depthdata=prof_diff_NO3;
        dat.data=data_diff_NO3;
        dat.londata=lon_diff_NO3;
        dat.latdata=lat_diff_NO3;
        %dat.londata=lon_stn_bot;
        %dat.latdata=lat_stn_bot;
  
    else
        disp('No NO3 data available')
        dat=[];
        return
    end
end

%size(dat.depthdata)
%size(dat.latdata)
% Conversion from dBars to meters.
dat.depthdata = sw_dpth(dat.depthdata,dat.latdata);
% ---- Clean the Structure ...
dat=rmfield(dat,'dummy');        
